package reno.ribbon.ribbon.rivenmarket;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import reno.ribbon.ribbon.common.JSONUtils;

@Service
public class RivenMarketService {

    @Autowired
    RestTemplate restTemplate;

//    @HystrixCommand(fallbackMethod = "getRivenMarketError")
    public JSONObject getRivenMarket(String weaponCn) {
        return restTemplate.getForObject("http://market/getRivenMarket" + "?weaponCn=" + weaponCn, JSONObject.class);
    }

    public JSONObject getRivenMarketError(String weaponCn) {
        return JSONUtils.failure("Sorry,Service invocation failed.");
    }

}
